package com.leetcode;

import java.util.Arrays;

/**
 * TODO
 *
 * @author lefly
 * @version 1.0
 * @classname No283
 * @description
 * @date 2021/1/30 下午5:01
 */
public class No283 {
    public static void main(String[] args) {
        int[] nums = {0, 1, 0, 3, 12};
        moveZeroes(nums);
        System.out.println(Arrays.toString(nums));
    }

    public static void moveZeroes(int[] nums) {
        if (nums == null || nums.length < 2) {
            return;
        }
        int len = nums.length, index = 0;
        for (int n : nums) {
            if(n != 0){
                nums[index++] = n;
            }
        }
        for (int j = index; j < len; j++) {
            nums[j] = 0;
        }
    }

}
